package com.ok.community.controller;


import com.ok.common.domain.po.Result;
import com.ok.community.domain.po.OkCommentCategory;
import com.ok.community.service.IOkBanService;
import com.ok.community.service.IOkCommentCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 帖子分类表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-04-29
 */
@Api(tags = "帖子分类相关接口")
@RestController
@RequestMapping("/cardCategory")
@RequiredArgsConstructor
public class OkCommentCategoryController {

    private final IOkCommentCategoryService okCommentCategoryService;

    @ApiOperation(value = "删除帖子分类")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        okCommentCategoryService.removeWith(id);
        return Result.success();
    }

    @ApiOperation(value = "增加帖子分类")
    @PostMapping("/add")
    public Result add(String name){
        OkCommentCategory okCommentCategory = new OkCommentCategory();
        okCommentCategory.setName(name);
        okCommentCategoryService.save(okCommentCategory);
        return Result.success();
    }

    @ApiOperation(value = "查询分类")
    @GetMapping("/list")
    public Result list(){
        List<OkCommentCategory> list = okCommentCategoryService.list();
        return Result.success(list);
    }
}
